package com.esri.core.tasks.geocode;

import com.esri.core.geometry.SpatialReference;
import com.esri.core.internal.util.d;
import com.esri.core.io.EsriServiceException;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class BatchGeocodeResult {
    private List<LocatorGeocodeResult> _locations = new ArrayList();
    private SpatialReference _spatialReference;

    void setSpatialReference(SpatialReference spatialReference) {
        this._spatialReference = spatialReference;
    }

    public SpatialReference getSpatialReference() {
        return this._spatialReference;
    }

    public List<LocatorGeocodeResult> getLocations() {
        return this._locations;
    }

    public static BatchGeocodeResult fromJson(JsonParser jsonParser) throws Exception {
        if (!d.c(jsonParser)) {
            throw new EsriServiceException("This response cannot be parsed.");
        }
        BatchGeocodeResult batchGeocodeResult = new BatchGeocodeResult();
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if ("spatialReference".equals(currentName)) {
                SpatialReference fromJson = SpatialReference.fromJson(jsonParser);
                if (fromJson != null) {
                    batchGeocodeResult.setSpatialReference(fromJson);
                }
            } else if ("locations".equals(currentName)) {
                while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                    LocatorGeocodeResult fromJson2 = LocatorGeocodeResult.fromJson(jsonParser);
                    if (fromJson2 != null) {
                        batchGeocodeResult._locations.add(fromJson2);
                    }
                }
            } else {
                jsonParser.skipChildren();
            }
        }
        return batchGeocodeResult;
    }
}
